// ==++==
// 
//   Copyright (c) 2008 Microsoft Corporation. All rights reserved.
//   License: MS-Pl
//
// ==--==

using System;
using System.Reflection;
using System.Text;
using System.Collections.Generic;
using Microsoft.ExtendedReflection.Metadata.Builders;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using Microsoft.Pex.Engine;
using Microsoft.Pex.Engine.Utilities;
using Microsoft.ExtendedReflection.Monitoring;
using Microsoft.ExtendedReflection.Utilities;
using Microsoft.ExtendedReflection.Metadata.Names;

namespace Pex.Xunit.Integration
{
    /// <summary>
    /// Summary description for IntegrationTest
    /// </summary>
    [TestClass]
    public class XunitIntegrationTest
    {
        private readonly string pexConsole = 
            PexInstallHelper.GetPexConsole(Bitness.x86);
        [TestMethod]
        public void ExecutePex()
        {
            PexEngineOptions options = PexEngineOptions.CreateDefault();
            options.DoNotOpenReport = true;
            options.CompileTestProject = true;
            options.TestNoPartialClasses = true;
            options.Assembly = typeof(XunitIntegrationTest).Assembly.Location;

            string arguments = String.Join(" ", options.GetCommandLineArguments(true));
            int exitCode = ProcessHelper.ExecuteCommand(
                pexConsole,
                arguments);
            Console.WriteLine("exit code {0} - {1}", exitCode, PexExitCodes.Describe(exitCode));
            Assert.AreEqual(PexExitCodes.Success, exitCode);
        }
    }

    [TestClass]
    public class XUnitFrameworkTests
    {
        [TestMethod]
        public void Ensure_TestFramework_Object_Can_Be_Created_By()
        {
            PexResultObserver observer = new PexResultObserver("TempPexObserver", false, "1");
            XunitTestFrameworkAttribute.TestFramework testFramework = new XunitTestFrameworkAttribute.TestFramework(observer);
            Assert.IsNotNull(testFramework);
        }
    }
}
